home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Answers 2002 January
/
PC Answers January 2002.7z
/
PC Answers January 2002.bin
/
graphics
/
freepixl
/
_SETUP.1
/
imgprint.pxl
< prev
next >
Wrap
Text File
|
2000-12-23
|
6KB
|
230 lines
{ Filename : imgprint.pxl
Purpose : print an image file from a command line
Date : 21 nov 98
Author : S.Dibbs, VYSOR Integration Inc
History:
Version : 1.0 RELEASE
Update :
Date :
--------------------------------------------------------------------------}
Initialize: {only one instance allowed}
UseCoordinates(PIXEL)
Title$ = "PiXCL Image Print Utility"
WinExist(Title$,Res)
If Res = 0 Then Goto One_Instance
Beep
WinSetActive(Title$,Res)
WinShow(Title$,RESTORE,Res)
End
One_Instance:
UseCaption(Title$) {change the title}
GetCmdLine(CommandLine$)
{MessageBox(OK,1,INFORMATION,CommandLine$,"Current Command Line",Res)}
GoSub ProcessCmdLine {returns Done}
WinLocate(Title$,354,118,906,513,Res)
UseBackground(TRANSPARENT,210,218,251)
WinShow(Title$,NOTOPMOST,Res)
DrawBackGround
DirGet(SourceDir$) {used later for library function calls}
DragAcceptFile(ENABLE,AcceptFile)
AutoProgressBar(DISABLE)
InfoMenu(REMOVE)
WaitInput(100)
SetMenu("&File",IGNORE,
"&New",CreatingFile,
"&Open",OpeningFile,
"&Save",SavingFile,
SEPARATOR,
"E&xit!",Terminate,
ENDPOPUP,
"&View",IGNORE,
"&ToolBar",ViewToolBar,
"&StatusBar",ViewStatusBar,
ENDPOPUP,
"&Information",IGNORE,
"&Concept",Concept,
"&Help",ShowAppHelp,
SEPARATOR,
"&About",About,
ENDPOPUP)
GoSub MakeToolbar
ChangeMenuItem("&ToolBar",CHECK,TBRes)
StatusWindow(ENABLE,BOTTOM,2,200,-1,0,0)
DrawStatusWinText(0,"Ready")
If Done = 0 Then DrawStatusWinText(0,"Print command failed")
ChangeMenuItem("&StatusBar",CHECK,SBRes)
Wait_for_Input:
WaitInput()
Terminate:
End
Concept:
MessageBox(OK,1,INFORMATION,
"This is a skeleton of a PiXCL application. You could briefly
describe your application's function here, or provide some
basic help information.",
"PiXCL Skeleton Concept",Res)
Goto Wait_for_Input
ShowAppHelp:
{An application Help file usually has the same name as the application.}
Winhelp("test.hlp",CONTENTS,"")
Goto Wait_for_Input
About:
AboutUser( Title$,
"Print an image from a command line.",
"Four Lines of additional information goes here, perhaps contact information and Web addresses")
Goto Wait_for_Input
ViewToolBar:
GetMenuStatus("&ToolBar",CHECKED,Res)
If Res = 0
GoSub MakeToolbar
ChangeMenuItem("&ToolBar",CHECK,Res)
Else
Toolbar()
ChangeMenuItem("&ToolBar",UNCHECK,Res)
Endif
Goto Wait_for_Input
ViewStatusBar:
GetMenuStatus("&StatusBar",CHECKED, Res)
If Res = 0
StatusWindow(ENABLE,BOTTOM,2,200,-1,0,0)
DrawStatusWinText(0,"Ready")
ChangeMenuItem("&StatusBar",CHECK,Res)
Else
StatusWindow(DISABLE,BOTTOM,2,200,-1,0,0)
ChangeMenuItem("&StatusBar",UNCHECK,Res)
Endif
Goto Wait_for_Input
CreatingFile:
{TODO: add file handling here}
{MessageBox(OK,1,INFORMATION,"No operation code for this button.","File New",Res)}
ListLoadedBitmaps(List$,"|",Count)
DrawText(10,30,List$)
DrawBitmap(10,60,Image$)
Goto Wait_for_Input
OpeningFile:
{TODO: add file handling here}
{MessageBox(OK,1,INFORMATION,"No operation code for this button.","File Open",Res) }
WaitInput(1)
UseCursor(WAIT)
Chr(10,Delimiter$)
Name$ = ""
EnumPrinters(LOCAL,NONSHARED,Name$,ONE,Delimiter$,PrinterNameList$,
PrinterDescList$,Res)
Len(PrinterNameList$,Res1)
DrawStatusWinText(1,PrinterNameList$)
Str(Res1,Res1$) DrawStatusWinText(1,Res1$)
UseCursor(ARROW)
If Res = 1
DrawTextExt(10,30,400,200,PrinterNameList$,LEFT)
Else
DrawStatusWinText(0,"EnumPrinters failed")
WaitInput(1500)
DrawStatusWinText(0,"Ready...")
Endif
Goto Wait_for_Input
SavingFile:
{TODO: add file handling here}
MessageBox(OK,1,INFORMATION,"No operation code for this button.","File Save",Res)
Goto Wait_for_Input
PrintingFile:
WaitInput(1)
Filter$ = "TIFF files (*.tif),*.tif"
Label$ = "Select a file to print"
InitFile$ = "*.tif"
InitDir$ = SourceDir$
FileGet(Filter$,InitFile$,InitDir$,Label$,CHANGEDIR,Image$)
If Image$ <> ""
PrintBitmap(Image$,PRINT_PAGERES, Res)
If Res = 0 Then DrawStatusWinText(0,"Print command failed")
Endif
Goto Wait_for_Input
AcceptFile:
GetDragList(FileList$)
{TODO: add file list handling here, or delete this whole label handler}
Goto Wait_for_Input
{--- Style Suggestion: place all subroutines at the end of the script.}
MakeToolbar: {subroutine}
Toolbar( RAISED, PXL_SMALL,
NULL, NULL, SEPARATOR, "", Wait_for_Input,
PXL_NEW, ENABLED, STD, "FileNew", CreatingFile,
PXL_OPEN, ENABLED, STD, "Enumerate Printers", OpeningFile,
PXL_SAVE, ENABLED, STD, "FileSave", SavingFile,
NULL, NULL, SEPARATOR, "", Wait_for_Input,
PXL_PRINT, ENABLED, STD,"Print", PrintingFile,
NULL, NULL, SEPARATOR, "", Wait_for_Input,
PXL_SHOHLP, ENABLED, STD,"Show Help",ShowAppHelp)
Return
ProcessCmdLine: {subroutine: check CommandLine$ for imgprint.exe}
Done = 0
Len(CommandLine$,Long)
If Long <= 9
MessageBox(OK,1,EXCLAMATION,"No image file specified.","Incomplete command line",Res)
End
Endif
Right(CommandLine$,3,Ext$)
Lcase(Ext$)
If Ext$ = "exe" Then Done = 0 Return
{get the file to print ... arg#1}
InStr(CommandLine$," ",Loc)
RightOf(CommandLine$,Loc,CommandLine$)
StrRev(CommandLine$) {remove leading and trailing spaces, if any}
Trim(CommandLine$)
StrRev(CommandLine$)
Trim(CommandLine$)
Image$ = CommandLine$
Trim(CommandLine$)
Trim(Image$)
FreeVar(CommandLine$)
FileExist(Image$,Res)
If Res = 0
MessageBox(OK,1,EXCLAMATION,Image$,"Image File does not exist",Res)
End
Endif
{
MessageBox(YESNO,2,QUESTION,"Load this file?",Image$,Res)
If Res = 2 Then Done = 1 Return
}
LoadBitmap(Image$,FULL)
PrintBitmap(Image$,PRINT_PTRRES, Res)
If Res = 1 Then End
Done = 0
Return